package com.changgou.goods.service.impl;

import com.changgou.goods.dao.ParaMapper;
import com.changgou.goods.pojo.Para;
import com.changgou.goods.service.ParaService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParaServiceImpl implements ParaService {
    @Autowired
    private ParaMapper paraMapper;

    /**
     * 新增参数
     * @param para
     */
    @Override
    public void add_para(Para para) {
        paraMapper.add_Para(para);
    }

    @Override
    public int delete_para(Integer id) {
        return paraMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Page<Para> findPage(int page, int size) {
        if (page<=0){
            page = 1;
        }
        if (size <=0){
            size = 10;
        }
        PageHelper.startPage(page,size);
        Page<Para> paras = (Page<Para>) paraMapper.selectAll();
        return paras;
    }
}
